package com.feng.study.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @Author: Zeng ShaoYong
 * @Date: 2022-04-27
 * @Description:
 */
@Aspect
@Component
@Slf4j
@Order(1)
public class TestAspect {

    @Around("execution(* com.feng.study.controller.*.*(..)) && @annotation(myAnnotationTestAspect)")
    public void aspectDemo01(ProceedingJoinPoint point,MyAnnotationTestAspect myAnnotationTestAspect){
        System.out.println("ANNOTATION welcome");
        System.out.println("ANNOTATION 调用方法："+ myAnnotationTestAspect);
        System.out.println("ANNOTATION 调用方法："+ myAnnotationTestAspect.methodName());
        System.out.println("ANNOTATION 调用类：" + point.getSignature().getDeclaringTypeName());
        System.out.println("ANNOTATION 调用类名" + point.getSignature().getDeclaringType().getSimpleName());
        Object[] args = point.getArgs();
        try {
            point.proceed(); //调用目标方法
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        System.out.println(args);
        System.out.println("ANNOTATION login success");
    }
}
